Skip to content

feat(mcptoolset): initiate interactive OAuth consent for MCP tools#1142

Draft
wolo-lab wants to merge 1 commit into
wolo/auth-consentfrom
wolo/auth-consent-gcp
Draft

feat(mcptoolset): initiate interactive OAuth consent for MCP tools#1142
wolo-lab wants to merge 1 commit into
wolo/auth-consentfrom
wolo/auth-consent-gcp

Conversation

@wolo-lab

@wolo-lab wolo-lab commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

The generic adk_request_credential consent round-trip existed, but nothing
triggered it for MCP: mcptoolset applies auth in the transport's RoundTripper,
which cannot start a consent flow (it has no function call id), and the MCP SDK
drops the underlying error chain — so a provider's auth.ConsentRequiredError
never reached the tool through CallTool. Interactive (3-legged) OAuth for MCP
tools therefore could not work.

This wires the interactive path for MCP:

  • mcptoolset passes Config.Auth to each tool and, before calling the server,
    probes the provider. If it returns auth.ConsentRequiredError, the tool calls
    ctx.RequestCredential (pausing the run for consent) and returns the new
    tool.ErrCredentialRequired sentinel. On success the provider caches the
    credential, so the RoundTripper reuses it on the actual call — no extra network
    round-trip for the common (GCP) case.
  • A non-consent resolution error fails fast with the real cause (the RoundTripper
    would fail the same way on the call below, but the MCP SDK would mangle the
    error chain).
  • ctx.AuthResponse guards the resume: once the user has consented, a provider
    that still cannot mint a credential fails instead of looping.
  • tool.ErrCredentialRequired is the credential analog of ErrConfirmationRequired;
    retryandreflect skips it like the other HITL sentinels.
  • Config.Auth documents that interactive consent is driven only during tool
    execution; tool listing (Tools) cannot pause, so a server that authenticates
    listing needs a non-interactive or already-consented credential.

@wolo-lab
wolo-lab force-pushed the wolo/auth-consent branch from dcca456 to 75e4317 Compare July 11, 2026 09:57
@wolo-lab
wolo-lab force-pushed the wolo/auth-consent-gcp branch from 360105c to ef4a912 Compare July 11, 2026 21:32
@wolo-lab
wolo-lab force-pushed the wolo/auth-consent branch from 75e4317 to 2ebe100 Compare July 11, 2026 21:46
@wolo-lab
wolo-lab force-pushed the wolo/auth-consent-gcp branch from ef4a912 to 0675063 Compare July 11, 2026 21:49
@wolo-lab
wolo-lab force-pushed the wolo/auth-consent branch from 2ebe100 to 3ed5bbe Compare July 11, 2026 22:34
@wolo-lab
wolo-lab force-pushed the wolo/auth-consent-gcp branch from 0675063 to d68a62f Compare July 11, 2026 22:39
The generic adk_request_credential consent round-trip existed, but nothing
triggered it for MCP: mcptoolset applies auth in the transport's RoundTripper,
which cannot start a consent flow (it has no function call id), and the MCP SDK
drops the underlying error chain — so a provider's auth.ConsentRequiredError
never reached the tool through CallTool. Interactive (3-legged) OAuth for MCP
tools therefore could not work.

This wires the interactive path for MCP:

- mcptoolset passes Config.Auth to each tool and, before calling the server,
  probes the provider. If it returns auth.ConsentRequiredError, the tool calls
  ctx.RequestCredential (pausing the run for consent) and returns the new
  tool.ErrCredentialRequired sentinel. On success the provider caches the
  credential, so the RoundTripper reuses it on the actual call — no extra network
  round-trip for the common (GCP) case.
- A non-consent resolution error fails fast with the real cause (the RoundTripper
  would fail the same way on the call below, but the MCP SDK would mangle the
  error chain).
- ctx.AuthResponse guards the resume: once the user has consented, a provider
  that still cannot mint a credential fails instead of looping.
- tool.ErrCredentialRequired is the credential analog of ErrConfirmationRequired;
  retryandreflect skips it like the other HITL sentinels.
- Config.Auth documents that interactive consent is driven only during tool
  execution; tool listing (Tools) cannot pause, so a server that authenticates
  listing needs a non-interactive or already-consented credential.

Testing: go build ./..., go test -race -shuffle=on ./..., golangci-lint run,
go mod tidy -diff — all green. New tests cover the consent request,
proceed-after-consent, the no-loop guard, fail-fast on a non-consent error, and
the no-provider path.
@wolo-lab
wolo-lab force-pushed the wolo/auth-consent-gcp branch from f66e8e0 to 3d28f93 Compare July 20, 2026 15:07
@wolo-lab wolo-lab changed the title Wolo/auth consent gcp feat(mcptoolset): initiate interactive OAuth consent for MCP tools Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant